package com.example.music.controller;


import com.example.commonutils.R;
import com.example.music.model.request.RankListRequest;
import com.example.music.service.RankListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AdminController
 * @Author: wx
 * @Create: 2022-10-04  17:12
 * @Description TODO
 * @Version: 1.0
 **/
@Api(description="评分操作")
@RestController
@CrossOrigin //解决跨域问题
public class RankListController {

    @Autowired
    private RankListService rankListService;


    // 提交评分
    @ApiOperation("提交评分")
    @PostMapping("/rankList/add")
    public R addRank(@RequestBody RankListRequest rankListAddRequest) {
        return rankListService.addRank(rankListAddRequest);
    }

    // 获取指定歌单的评分
    @ApiOperation("获取指定歌单的评分")
    @GetMapping("/rankList")
    public R rankOfSongListId(@RequestParam Long songListId) {
        return rankListService.rankOfSongListId(songListId);
    }

    // 获取指定用户的歌单评分
    @ApiOperation("获取指定用户的歌单评分")
    @GetMapping("/rankList/user")
    public R getUserRank(@RequestParam Long consumerId, @RequestParam Long songListId) {
        return rankListService.getUserRank(consumerId, songListId);
    }
}
